package com.h3c.nem.task;

import com.h3c.nem.service.ITbWorkerService;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.IJobHandler;
import com.xxl.job.core.handler.annotation.JobHandler;
import com.xxl.job.core.log.XxlJobLogger;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@JobHandler(value="syncNewWorkerHrssHandler")
@Component
@Slf4j
public class SyncNewWorkerHrssHandler extends IJobHandler {

    @Autowired
    ITbWorkerService workerService;

    @Override
    public ReturnT<String> execute(String s) throws Exception {
        XxlJobLogger.log("XXL-JOB, scheduledJobHandler.");
        log.info("从hrss同步待入职员工");
        try {
            log.info("入参:" + s);
            workerService.syncWorkerByHrss();
        }catch (Exception e){
            e.printStackTrace();
            XxlJobLogger.log(e.getMessage());
            return FAIL;
        }
        log.info("从hrss同步待入职员工成功");
        return SUCCESS;
    }
}
